import java.util.Arrays;
import java.util.Comparator;

public class ArraySort {
    public static void main(String[] args) {

        int[] position = new int[]{10,8,0,5,6};
        int[] speed = new int[]{2,4,1,1,3};
        int target = 12;
        int target2 = 12;

        car1[] car1s = new car1[speed.length];
        for (int i = 0; i < speed.length; i++) {
            car1s[i] = new car1(position[i],(double)((target - position[i])/speed[i]));
        }

        Arrays.sort(car1s,(a1, a2) ->{
            return Integer.compare(a2.pos,a1.pos);
        });

        for (car1 car1 : car1s) {
            System.out.println(car1);
        }

    }
}

class car1 {
    public int pos;
    public double ti;

    public car1(int pos, double ti) {
        this.pos = pos;
        this.ti = ti;
    }

    @Override
    public String toString() {
        return "car1{  "+pos+"  ," + ti + '}';
    }
}


class Goods {

    private String name;
    private double price;

    public String getName() {
        return name;
    }

    public double getPrice() {
        return price;
    }

    public Goods(String name, double price) {
        this.name = name;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Goods{" + price + "=" + price +
                "  name='" + name + '\'' +
                '}';
    }

}


